package com.demo;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.springframework.core.ResolvableType;
import org.springframework.util.ReflectionUtils;

import com.alibaba.fastjson.JSON;
import com.apidoc.enumeration.DataType;
import com.demo.web.User;
import com.demo.web.test.UserController1;

import cn.hutool.core.util.ReflectUtil;

public class Test {


	static List<User> list = new ArrayList<User>() ;
	
	public static void main(String args[]) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException {
		
		Class<?> cl1 = UserController1.class ;
		System.out.println(cl1.getName());
		System.out.println(cl1.getSimpleName());
		System.out.println(cl1.getCanonicalName());
		
		
		Class<?> clazz = DataType.class ;
		System.out.println(clazz.getName()) ;
		
		System.out.println(Enum.class.isAssignableFrom(clazz)) ;
		/*
		System.out.println(clazz.getDeclaredClasses()) ;*/
		
		
		Object[] objs = clazz.getEnumConstants(); 
		for(Object object : objs) {
			System.err.println("---" + ReflectUtil.getMethod(clazz, "enumApiDocs").invoke(object) + "---" );
		}
		System.out.println(JSON.toJSONString(objs));
		
	/*	String isString = DataType.enumApiDocs() ;
		
		isString = DataType.enumApiDoc() ;*/
	//	System.err.println(isString) ;
		System.err.println("-----------------------");
		
		
		System.out.println(List.class.getName());
		System.out.println(Double.class.getName());
		System.out.println(User.class.getName());
		
		Field[] fields = ReflectUtil.getFields(User.class);
		
		for(Field field : fields) {
			System.out.println(field.getGenericType().toString());
			System.out.println(field.getType().toString());
		}
		
		System.out.println("-----------------------");
		
		System.out.println(list.getClass());
		
		System.out.println(list.getClass().isAssignableFrom(List.class));
		
		System.out.println(List.class.isAssignableFrom(list.getClass()));
		
		System.out.println(Collection.class.isAssignableFrom(list.getClass()));
		
		System.out.println(Collection.class.isAssignableFrom(Map.class));
		
		System.out.println(Collection.class.isAssignableFrom(Set.class));
		
		ResolvableType resolvableType4 = ResolvableType.forInstance(list) ;
		//ResolvableType resolvableType4 =  ResolvableType.forClass(list.getClass()) ;
		//ResolvableType resolvableType4 =   ResolvableType.forField(ReflectionUtils.findField(Test.class, "list"));  
		System.out.println( resolvableType4.getGeneric(0).resolve()) ;  
		
	}
}
